<template>
  <div class="base">
    <img v-if="checkIcon()" :src="icon" />
    <div class="title">{{ title || "标题" }}</div>
    <div
      class="content"
      :style="{ height: Number(height) ? `${height}px` : height }"
    >
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "DashboardCard",
  props: {
    title: {
      type: [Number, String],
      default() {
        return "";
      }
    },
    height: {
      type: [Number, String],
      default() {
        return "100px";
      }
    },
    icon: {
      type: [Number, String],
      default() {
        return "";
      }
    }
  },
  methods: {
    checkIcon() {
      if (this.icon == "") return false;
      return true;
    }
  }
};
</script>

<style lang="scss" scoped>
.base {
  width: calc(100% - 20px);
  height: 100%;
  border-radius: 3px;
  .title {
    font-size: 18px;
    font-weight: bold;
    display: inline-block;
  }
  .content {
    margin-top: 10px;
    background: #fff;
    box-shadow: 0 0 4px 1px #ddd;
    padding: 20px;
    height: 100px;
  }
  img {
    width: auto;
    height: 24px;
    margin-right: 0.3rem;
    margin-bottom: -0.3rem;
  }
}
</style>
